package com.zyt.service.Impl;

import com.zyt.mapper.DeptMapper;
import com.zyt.pojo.Dept;
import com.zyt.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class DeptServiceImpl implements DeptService {
    @Override
    public void update(Dept dept) {
        //补全基础属性 - update_time
        dept.setUpdateTime(LocalDateTime.now());
        //调用mapper插入数据
        deptMapper.update(dept);
    }

    @Override
    public Dept getByid(Integer id) {
        return deptMapper.getByid(id);
    }

    @Override
    public void add(Dept dept) {
        //补全基础属性 - create_time,update_time
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        //调用mapper插入数据
        deptMapper.insert(dept);
    }

    @Autowired
    private DeptMapper deptMapper;
    @Override
    public List<Dept> findAll() {

        return deptMapper.findAll();
    }

    @Override
    public void delete(Integer id) {
      deptMapper.delete(id);
    }


}
